Skip to content

feat(micrometer): [Micrometer 4] Add Spring Boot integration - #6116

Draft
adinauer wants to merge 10 commits into
feat/micrometer-function-timerfrom
feat/micrometer-spring-boot
Draft

adinauer wants to merge 10 commits into
feat/micrometer-function-timerfrom
feat/micrometer-spring-boot

Conversation

@adinauer

@adinauer adinauer commented Sep 15, 2026

Copy link
Copy Markdown
Member

PR Stack (Micrometer)


📜 Description

Closes #6149

Add opt-in Micrometer integration for Spring Boot 2, 3, and 4.

When sentry-micrometer and Micrometer are on the classpath, setting sentry.micrometer.enabled=true creates a SentryMeterRegistry bean that Spring adds to its composite registry. sentry.micrometer.poll-interval-millis controls passive polling and defaults to 60 seconds.

The artifact remains optional and is not added transitively by the existing starters. The Spring Boot samples add Actuator and verify that active HTTP metrics and passively polled process metrics reach real Sentry metric envelopes.

💡 Motivation and Context

Spring Boot applications commonly use Micrometer through Actuator. Thin conditional configuration lets those applications add Sentry as another metrics destination without replacing existing registries or enabling the integration merely because a class happens to be present.

Importing the configuration from the existing Sentry auto-configuration keeps lifecycle and initialization ordering aligned across all three supported Spring Boot generations.

💚 How did you test it?

./gradlew spotlessApply apiDump
./gradlew :sentry-micrometer:check :sentry-spring-boot:test :sentry-spring-boot-jakarta:test :sentry-spring-boot-4:test

The Spring Boot 2, 3, and 4 MetricsSystemTest suites also passed against the repository mock Sentry server on port 18080. They verify http.server.requests active metrics and passively polled process.uptime metrics in captured envelopes.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Complete cross-SDK documentation and evaluate build-plugin installation separately.

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

Add opt-in Micrometer registry configuration for Spring Boot 2, 3, and 4 when the sentry-micrometer artifact is present.\n\nExpose polling configuration, register the Sentry registry with Spring's composite registry, and verify active and passive metric delivery through sample system tests.\n\nCo-Authored-By: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 2d0c4ca

@sentry

sentry Bot commented Sep 15, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.56.0 (1) release

⚙️ sentry-android Build Distribution Settings

adinauer and others added 6 commits September 17, 2026 16:22
Update Spring Boot system test expectations to match the Sentry registry's dot naming convention.

Co-Authored-By: Claude <noreply@anthropic.com>
Document generation-specific starter coordinates so Spring Boot 2 and 3 users can adapt the Boot 4 setup example.

Co-Authored-By: Claude <noreply@anthropic.com>
@Bean(destroyMethod = "close")
@ConditionalOnMissingBean(SentryMeterRegistry.class)
public @NotNull SentryMeterRegistry sentryMeterRegistry(
final @NotNull IScopes scopes, final @NotNull SentryProperties properties) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scopes is never used in the SentryMicrometerConfiguration classes. is this just to make sure that IScopes are initialized before the registry is created?

return "count metric increased";
}

@GetMapping("micrometer")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this is only added in spring-boot, but not in the spring-boot-jakarta and spring-boot-4 variants?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add samples to other versions too.

Use the supplied IScopes for metric recording and diagnostic logging
instead of bypassing it through the static Sentry API. Default standalone
constructors to ScopesAdapter so current-context resolution is preserved.

Pass the Spring scopes bean through all three Boot integrations while
retaining initialization ordering. Cover injected metrics, logging, and
Spring wiring with regression tests.

Refs #6116
Co-Authored-By: Claude <noreply@anthropic.com>
adinauer added a commit that referenced this pull request Sep 23, 2026
Merge the Spring Boot registry scopes change from #6116 into #6155.
Use the same injected scopes for registration filtering and recording so
custom scopes do not accidentally inherit global ignored-metric options.

Resolve test imports, supply options in injected-scope fixtures, and cover
filtering with distinct global and injected ignore lists. Preserve the
existing logging defaults and explicit override behavior.

Refs #6116
Refs #6155
Co-Authored-By: Claude <noreply@anthropic.com>
Copy the Boot 2 Micrometer endpoint and secondary SimpleMeterRegistry into
the Jakarta and Boot 4 samples. Verify that a single recording reaches
both Sentry and the secondary registry, including exported tags and SDK
integration metadata.

Run the six metrics system tests for each of Boot 2, 3, and 4 against the
sample applications and mock Sentry server: all 18 pass.

Refs #6116
Co-Authored-By: Claude <noreply@anthropic.com>
adinauer added a commit that referenced this pull request Sep 23, 2026
Merge the Boot 3 and Boot 4 sample endpoints and dual-registry system tests
from #6116 into the ignored-metrics branch. Keep the top of the stack in
sync without rewriting its history.

Verify all 18 metrics system tests against Boot 2, 3, and 4 with the
ignored-metrics defaults applied. Formatting and API checks also pass.

Refs #6116
Refs #6155
Co-Authored-By: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants